using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Linq;

namespace MyPublisher.Storage
{
	public abstract class Storage : IDisposable
	{
        public string Name { get; set; }

        public StorageConnectionString ConnectionString { get;  private set; }
  
        protected Storage() 
        {
            ConnectionString = new StorageConnectionString();
        }

        public void Initialize(string name, string connectionString)
        {
            ConnectionString = StorageConnectionString.Parse(connectionString);
        }

        public abstract string Type { get; }
        public abstract void Open();
        public abstract void Close();
        public abstract void ResolvePath(ref string path);
        public abstract Stream OpenFile(string path);
        public abstract Stream CreateFile(string path);
        public abstract bool IsFileExists(string path);
        public abstract void DeleteFile(string path);
        public abstract string[] GetFiles(string path, string pattern, bool recursive);
	
        public void  Dispose()
        {
            Close();
 	        Dispose(true);
        }
        protected virtual void Dispose(bool dispose){}
    }
}
